package com.lixiaoyi.ems.controller;

import com.lixiaoyi.ems.entity.Emp;
import com.lixiaoyi.ems.service.IEmpService;
import com.lixiaoyi.ems.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * @Author 李小毅
 * @Description
 * @Date 2022-05-18
 */
@WebServlet("/manager/safe/showEmp")
public class ShowEmpController extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //收参
        Integer id = Integer.valueOf(request.getParameter("id"));

        //调用service层方法
        IEmpService empService = new EmpServiceImpl();
        Emp emp = empService.selectEmpById(id);

        //临时数据 存在作用域中
        request.setAttribute("emp",emp);
        request.getRequestDispatcher("/updateEmp.jsp").forward(request,response);



    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
